<!doctype html>
<html>
<head>
<meta name="viewport"
	content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0">

</head>
<body>
	<h1>WebViewJavascriptBridge Demo</h1>
	<script>

    function setupWebViewJavascriptBridge(callback) {
        if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
        if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
        window.WVJBCallbacks = [callback];
        var WVJBIframe = document.createElement('iframe');
        WVJBIframe.style.display = 'none';
        WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
        document.documentElement.appendChild(WVJBIframe);
        setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
    }
    setupWebViewJavascriptBridge(function(bridge) {

		bridge.registerHandler('testJavascriptHandler', function(data, responseCallback) {			
			var responseData = { 'Javascript Says':'Right back atcha!' }			
			responseCallback(responseData)
		})	

		var callbackButton = document.getElementById('buttons');		
		callbackButton.onclick = function(e) {
			e.preventDefault()			
			bridge.callHandler('testObjcCallback', {'foo': 'bar'}, function(response) {
				
			})
		}
	})
	</script>
	<div id='buttons'>测试按钮</div>
	<div id='log'></div>
</body>
</html>
